package com.paradise.ytj.view;

import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Canvas;
import android.util.AttributeSet;
import android.widget.RadioGroup;

import com.paradise.ytj.R;

/**
 * Created by Administrator on 2017/12/1 0001.
 */

public class CustomRadioGroup extends RadioGroup {
    private Context context;
    private int heightPixels;
    private int widthPixels;
    private Bitmap bitmap;

    public CustomRadioGroup(Context context) {
        super(context);
        this.context = context;
        init();
    }

    public CustomRadioGroup(Context context, AttributeSet attrs) {
        super(context, attrs);
        this.context = context;
        init();
    }

    private void init() {
        heightPixels = context.getResources().getDisplayMetrics().heightPixels;
        widthPixels = context.getResources().getDisplayMetrics().widthPixels;
        bitmap = BitmapFactory.decodeResource(context.getResources(), R.drawable.iv_menu_normal);
    }

    @Override
    protected void onDraw(Canvas canvas) {
        super.onDraw(canvas);
    }

    @Override
    protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
        super.onMeasure(widthMeasureSpec, heightMeasureSpec);
        setMeasuredDimension(widthPixels, (int) (heightPixels * 0.16) - bitmap.getHeight());
    }
}
